From 4331d13d8701cbd0217ecbe593df100b81693ef2 Mon Sep 17 00:00:00 2001 From: Rob Church Date: Fri, 8 Jun 2007 15:56:32 +0000 Subject: [PATCH] * (bug 10181) Support the XCache object caching mechanism [patch from Kurt Radwanski] * Minor tweak to installer form --- RELEASE-NOTES | 1 + config/index.php | 29 +++++++++++++++++-------- includes/AutoLoader.php | 1 + includes/BagOStuff.php | 46 ++++++++++++++++++++++++++++++++++++++++ includes/ObjectCache.php | 2 ++ 5 files changed, 70 insertions(+), 9 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 93eef9e745..2c02dd31ff 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -69,6 +69,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 8760) Allow wiki links in "protectexpiry" message * (bug 5908) Add "DEFAULTSORTKEY" and "DEFAULTCATEGORYSORT" aliases for "DEFAULTSORT" magic word +* (bug 10181) Support the XCache object caching mechanism == Bugfixes since 1.10 == diff --git a/config/index.php b/config/index.php index 30d5ccaf0f..20c1581e09 100644 --- a/config/index.php +++ b/config/index.php @@ -450,6 +450,10 @@ if ( $conf->turck ) { print "
  • Turck MMCache installed
  • \n"; } +$conf->xcache = function_exists( 'xcache_get' ); +if( $conf->xcache ) + print "
  • XCache installed
  • "; + $conf->apc = function_exists('apc_fetch'); if ($conf->apc ) { print "
  • APC installed
  • "; @@ -461,10 +465,11 @@ if ( $conf->eaccel ) { print "
  • eAccelerator installed
  • \n"; } -if( !$conf->turck && !$conf->eaccel && !$conf->apc ) { +if( !( $conf->turck || $conf->eaccel || $conf->apc || $conf->xcache ) ) { echo( '
  • Couldn\'t find Turck MMCache, - eAccelerator, or - APC. Object caching functions cannot be used.
  • ' ); + eAccelerator, + APC or XCache. + Object caching functions cannot be used.' ); } $conf->diff3 = false; @@ -1128,8 +1133,7 @@ if( count( $errs ) ) {

    An admin can lock/delete pages, block users from editing, and do other maintenance tasks.
    A new account will be added only when creating a new wiki database. -

    -

    +

    The password cannot be the same as the username.

    @@ -1144,6 +1148,11 @@ if( count( $errs ) ) { aField( $conf, "Shm", "Turck MMCache", "radio", "turck" ); echo ""; } + if( $conf->xcache ) { + echo( '
  • ' ); + aField( $conf, 'Shm', 'XCache', 'radio', 'xcache' ); + echo( '
  • ' ); + } if ( $conf->apc ) { echo "
  • "; aField( $conf, "Shm", "APC", "radio", "apc" ); @@ -1160,10 +1169,11 @@ if( count( $errs ) ) {

    - Using a shared memory system such as Turck MMCache, APC, eAccelerator, or Memcached - will speed up MediaWiki significantly. Memcached is the best solution but needs to be - installed. Specify the server addresses and ports in a comma-separated list. Only - use Turck shared memory if the wiki will be running on a single Apache server. + An object caching system such as memcached will provide a significant performance boost, + but needs to be installed. Provide the server addresses and ports in a comma-separated list. +

    + MediaWiki can also detect and support eAccelerator, Turck MMCache, APC, and XCache, but + these should not be used if the wiki will be running on multiple application servers.

    @@ -1395,6 +1405,7 @@ function writeLocalSettings( $conf ) { $mcservers = var_export( $conf->MCServerArray, true ); break; case 'turck': + case 'xcache': case 'apc': case 'eaccel': $cacheType = 'CACHE_ACCEL'; diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index 06e5b37937..7f9a499ccb 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -22,6 +22,7 @@ function __autoload($className) { 'TurckBagOStuff' => 'includes/BagOStuff.php', 'APCBagOStuff' => 'includes/BagOStuff.php', 'eAccelBagOStuff' => 'includes/BagOStuff.php', + 'XCacheBagOStuff' => 'includes/BagOStuff.php', 'DBABagOStuff' => 'includes/BagOStuff.php', 'Block' => 'includes/Block.php', 'HTMLFileCache' => 'includes/HTMLFileCache.php', diff --git a/includes/BagOStuff.php b/includes/BagOStuff.php index 1174997d0c..5cb14d9d4d 100644 --- a/includes/BagOStuff.php +++ b/includes/BagOStuff.php @@ -564,6 +564,52 @@ class eAccelBagOStuff extends BagOStuff { } } +/** + * Wrapper for XCache object caching functions; identical interface + * to the APC wrapper + */ +class XCacheBagOStuff extends APCBagOStuff { + + /** + * Get a value from the XCache object cache + * + * @param string $key Cache key + * @return mixed + */ + public function get( $key ) { + $val = xcache_get( $key ); + if( is_string( $val ) ) + $val = unserialize( $val ); + return $val; + } + + /** + * Store a value in the XCache object cache + * + * @param string $key Cache key + * @param mixed $value Object to store + * @param int $expire Expiration time + * @return bool + */ + public function set( $key, $value, $expire = 0 ) { + xcache_set( $key, serialize( $value ), $expire ); + return true; + } + + /** + * Remove a value from the XCache object cache + * + * @param string $key Cache key + * @param int $time Not used in this implementation + * @return bool + */ + public function delete( $key, $time = 0 ) { + xcache_unset( $key ); + return true; + } + +} + /** * @todo document */ diff --git a/includes/ObjectCache.php b/includes/ObjectCache.php index a493a75c26..32ae5d3bc0 100644 --- a/includes/ObjectCache.php +++ b/includes/ObjectCache.php @@ -70,6 +70,8 @@ function &wfGetCache( $inputType ) { $wgCaches[CACHE_ACCEL] = new eAccelBagOStuff; } elseif ( function_exists( 'apc_fetch') ) { $wgCaches[CACHE_ACCEL] = new APCBagOStuff; + } elseif( function_exists( 'xcache_get' ) ) { + $wgCaches[CACHE_ACCEL] = new XCacheBagOStuff(); } elseif ( function_exists( 'mmcache_get' ) ) { $wgCaches[CACHE_ACCEL] = new TurckBagOStuff; } else { -- 2.20.1